<?php
namespace library\core;
if (!defined('ROOT')) exit('Can\'t Access !');

/**
 * 配置操作类
 * Class config
 */
class config
{
    /**
     * 获取参数，可以传入键名：root.children.cchildren;表示获取params['root']['children']['cchildren'];
     * return  找到相应的参数就返回设定的值，否则返回null
     */
    public function get($key)
    {
        $params = include(PATH.'include/config.php');

        if(strpos($key, '.')>0){
            $keys = explode('.',$key);
            $p = $params;
            foreach($keys as $key){
                if(isset($p[$key])){
                    $p = $p[$key];
                }else{
                    return null;
                }
            }
            return $p;
        }else{
            return $params[$key];
        }
    }
}
?>